// 
// File:   MyImg.h
// Author: ben
//
// Created on October 13, 2008, 3:05 PM
//

#ifndef _MYIMG_H
#define	_MYIMG_H

#include <iostream>
#include <string>
#include <fstream>
#include <math.h>
#include <vector>

//#include <highgui.h>
#include <opencv/highgui.h>
//#include <cv.h>
#include <opencv/cv.h>

#include <fftw3.h>

#define GRAYSCALE_MODE 1
#define COLOR_MODE_R 4
#define COLOR_MODE_G 3
#define COLOR_MODE_B 2

using namespace std;

class MyImg{
public:
	string getFilename(){return(thisFilename);};
	void setFilename(string NewFname){thisFilename=NewFname;Clean();};
	int Show();
	MyImg();
        ~MyImg();
	int ComputeFFT();
	int ComputeFFTw();
	
	//int ComputeHist();
	
	double ValFFT(int x,int y,bool IsRealPart,int mode);
        double ValFFT(int x,int y,bool IsRealPart);
	int getHeight(){return(thisHeight);}
	int getWidth(){return(thisWidth);}
	
	
	int addTag(string newtag);
	int nTags(){return(thisTags.size());}
	string getTag(int i){if(i<nTags()){return(thisTags[i]);}else{return("UNKNOWN");}}
	int ShowTags();
	
	int ApplyFilter();
	void setFFT(int x, int y, bool IsRealPart,double val);
        void setFFT(int x, int y, bool IsRealPart,double val,int mode);
        void Test();

        int ComputeMultiFFTw();
        int ComputeFFTwGeneral(int input);

        void OpenImage(int mode);

        void Clean();
	
private:
	string thisFilename;
	void cvShiftDFT(CvArr * src_arr, CvArr * dst_arr );
	bool FFTexist;
        bool IsFFTcomputed(int mode);
	
	int thisWidth;
	int thisHeight;
	int thisStep;
	fftw_complex    *fft;
        fftw_complex    *fftR;
        fftw_complex    *fftG;
        fftw_complex    *fftB;
	//CvHistogram	*hist;
	
	vector<string> thisTags;

        IplImage* thisimg;
};


#endif	/* _MYIMG_H */

